package com.neuedu.dao.impl;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.neuedu.dao.GoodsDao;
import com.neuedu.dao.UserMessageDao;
import com.neuedu.model.Goods;
//把dao接口实现类，交给spring进行管理
@Repository
public class GoodsDaoImpl implements GoodsDao {

	//代码层级的整合spring+mybatis
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
		this.sqlSessionTemplate = sqlSessionTemplate;
	}
	
	@Override
	public int countGoods() {
		return sqlSessionTemplate.getMapper(GoodsDao.class).countGoods();
	}

	@Override
	public List<Goods> findAll(Map<String, Object> map) {
		return sqlSessionTemplate.getMapper(GoodsDao.class).findAll(map);
	}

	@Override
	public int addGoods(Goods u) {
		return sqlSessionTemplate.getMapper(GoodsDao.class).addGoods(u);
	}

	@Override
	public int updateGoods(Goods u) {
		return  sqlSessionTemplate.getMapper(GoodsDao.class).updateGoods(u);
	}

	@Override
	public int deleteGoods(int id) {
		return sqlSessionTemplate.getMapper(GoodsDao.class).deleteGoods(id);
	}

	@Override
	public List<Goods> findList() {
		return sqlSessionTemplate.getMapper(GoodsDao.class).findList();
	}

}
